package com.osfw.system.entity.monitor;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.osfw.framework.core.entity.BasicEntity;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.Date;

/**
 * 操作日志记录表 oper_log
 */
@Data
@Accessors(chain = true)
public class SysOperLog extends BasicEntity {
    private static final long serialVersionUID = 1L;

    /* 日志主键 */
    @TableId(value = "oper_id_", type = IdType.ASSIGN_ID)
    private Long operId;

    /* 操作模块 */
    @TableField(value = "title_")
    private String title;

    /* 业务类型（0其它 1新增 2修改 3删除） */
    @TableField(value = "business_type_")
    private Integer businessType;

    /* 业务类型数组 */
    @TableField(exist = false)
    private Integer[] businessTypes;

    /* 请求方法 */
    @TableField(value = "method_")
    private String method;

    /* 请求方式 */
    @TableField(value = "request_method_")
    private String requestMethod;

    /* 操作类别（0其它 1后台用户 2手机端用户） */
    @TableField(value = "operator_type_")
    private Integer operatorType;

    /* 操作人员 */
    @TableField(value = "oper_name_")
    private String operName;

    /* 部门名称 */
    @TableField(value = "dept_name_")
    private String deptName;

    /* 请求url */
    @TableField(value = "oper_url_")
    private String operUrl;

    /* 操作地址 */
    @TableField(value = "oper_ip_")
    private String operIp;

    /* 操作地点 */
    @TableField(value = "oper_location_")
    private String operLocation;

    /* 请求参数 */
    @TableField(value = "oper_param_")
    private String operParam;

    /* 返回参数 */
    @TableField(value = "json_result_")
    private String jsonResult;

    /* 操作状态（0正常 1异常） */
    @TableField(value = "status_")
    private Integer status;

    /* 错误消息 */
    @TableField(value = "error_msg_")
    private String errorMsg;

    /* 操作时间 */
    @TableField(value = "oper_time_", fill = FieldFill.INSERT)
    private Date operTime;

    /* 消耗时间 */
    @TableField(value = "cost_time_")
    private Long costTime;


    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("operId", getOperId())
                .append("title", getTitle())
                .append("businessType", getBusinessType())
                .append("businessTypes", getBusinessTypes())
                .append("method", getMethod())
                .append("requestMethod", getRequestMethod())
                .append("operatorType", getOperatorType())
                .append("operName", getOperName())
                .append("deptName", getDeptName())
                .append("operUrl", getOperUrl())
                .append("operIp", getOperIp())
                .append("operLocation", getOperLocation())
                .append("operParam", getOperParam())
                .append("status", getStatus())
                .append("errorMsg", getErrorMsg())
                .append("operTime", getOperTime())
                .append("costTime", getCostTime())
                .toString();
    }
}
